funk101
05/20/2022, 4:19 AMhas been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
I'm wondering if it has something to do with NextCors
middleware? Any ideas?Ahnaf
05/20/2022, 4:27 AMAhnaf
05/20/2022, 4:27 AMAhnaf
05/20/2022, 4:27 AMAhnaf
05/20/2022, 4:27 AMAhnaf
05/20/2022, 4:27 AMAhnaf
05/20/2022, 4:28 AMAhnaf
05/20/2022, 4:28 AMfunk101
05/20/2022, 4:29 AMAhnaf
05/20/2022, 4:29 AMfunk101
05/20/2022, 4:29 AMPOST https://finicky.pet/api/auth/session/refresh net::ERR_FAILED
Ahnaf
05/20/2022, 4:29 AMfunk101
05/20/2022, 4:29 AMfunk101
05/20/2022, 4:30 AMAhnaf
05/20/2022, 4:30 AMfunk101
05/20/2022, 4:31 AMfunk101
05/20/2022, 4:31 AMAhnaf
05/20/2022, 4:32 AMAhnaf
05/20/2022, 4:32 AMAhnaf
05/20/2022, 4:32 AMfunk101
05/20/2022, 4:33 AMrp_st
05/20/2022, 4:33 AMAhnaf
05/20/2022, 4:33 AMAhnaf
05/20/2022, 4:33 AMfunk101
05/20/2022, 4:33 AMfunk101
05/20/2022, 4:33 AMAhnaf
05/20/2022, 4:33 AMAhnaf
05/20/2022, 4:34 AMrp_st
05/20/2022, 4:34 AMAhnaf
05/20/2022, 4:34 AMfunk101
05/20/2022, 4:34 AMfunk101
05/20/2022, 4:34 AMAhnaf
05/20/2022, 4:34 AMAhnaf
05/20/2022, 4:35 AMrp_st
05/20/2022, 4:35 AMAhnaf
05/20/2022, 4:35 AMAhnaf
05/20/2022, 4:35 AMAhnaf
05/20/2022, 4:35 AMrp_st
05/20/2022, 4:36 AMrp_st
05/20/2022, 4:36 AMfunk101
05/20/2022, 4:37 AMfunk101
05/20/2022, 4:38 AMif (typeof window !== "undefined") {
// we only want to call this init function on the frontend, so we check typeof window !== 'undefined'
SuperTokensReact.init(frontendConfig());
}
const EmailPasswordAuthNoSSR = dynamic(
new Promise((res) => res(EmailPassword.EmailPasswordAuth)),
{ ssr: false }
);
export default function App({ Component, pageProps }) {
const securityLevel = Component.securityLevel;
const getLayout = Component.getLayout || ((page) => page);
if (securityLevel === "full") {
return (
<EmailPasswordAuthNoSSR>
{getLayout(<Component {...pageProps} />)}
</EmailPasswordAuthNoSSR>
);
} else {
return (
<EmailPasswordAuthNoSSR requireAuth={false}>
{getLayout(<Component {...pageProps} />)}
</EmailPasswordAuthNoSSR>
);
}
}
rp_st
05/20/2022, 4:38 AMfunk101
05/20/2022, 4:39 AMexport const appInfo = {
// learn more about this on https://supertokens.com/docs/emailpassword/appinfo
appName: "finicky.pet-v4",
apiDomain: process.env.NEXT_PUBLIC_HOST,
websiteDomain: process.env.NEXT_PUBLIC_HOST,
apiBasePath: "/api/auth",
websiteBasePath: "/auth",
};
rp_st
05/20/2022, 4:39 AMprocess.env.NEXT_PUBLIC_HOST
?Ahnaf
05/20/2022, 4:40 AMAhnaf
05/20/2022, 4:40 AMAhnaf
05/20/2022, 4:40 AMfunk101
05/20/2022, 4:40 AMAhnaf
05/20/2022, 4:40 AMAhnaf
05/20/2022, 4:40 AMAhnaf
05/20/2022, 4:40 AMAhnaf
05/20/2022, 4:40 AMAhnaf
05/20/2022, 4:40 AMAhnaf
05/20/2022, 4:41 AMfunk101
05/20/2022, 4:41 AMAhnaf
05/20/2022, 4:41 AMfunk101
05/20/2022, 4:42 AMAhnaf
05/20/2022, 4:42 AMAhnaf
05/20/2022, 4:42 AMrp_st
05/20/2022, 4:42 AMAhnaf
05/20/2022, 4:42 AMfunk101
05/20/2022, 4:42 AMappInfo,
recipeList: [
EmailPasswordReact.init({
getRedirectionURL: async (context) => {
if (context.action === "SUCCESS") {
if (context.redirectToPath !== undefined) {
// navigate back to where the user was before authenticated
return context.redirectToPath;
}
return "/dashboard";
}
return undefined;
},
rp_st
05/20/2022, 4:42 AMfunk101
05/20/2022, 4:43 AMrp_st
05/20/2022, 4:43 AMAhnaf
05/20/2022, 4:43 AMfunk101
05/20/2022, 4:43 AMsupertokens.init(backendConfig());
export default async function superTokens(req, res) {
// NOTE: We need CORS only if we are querying the APIs from a different origin
await NextCors(req, res, {
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
origin: process.env.NEXT_PUBLIC_HOST,
credentials: true,
allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
});
await superTokensNextWrapper(
async (next) => {
await middleware()(req, res, next);
},
req,
res
);
if (!res.writableEnded) {
res.status(404).send("Not found");
}
}
Ahnaf
05/20/2022, 4:43 AMAhnaf
05/20/2022, 4:44 AMrp_st
05/20/2022, 4:44 AMAhnaf
05/20/2022, 4:44 AMfunk101
05/20/2022, 4:44 AMprocess.env.NEXT_PUBLIC_HOST
?rp_st
05/20/2022, 4:44 AMAhnaf
05/20/2022, 4:45 AMfunk101
05/20/2022, 4:45 AMrp_st
05/20/2022, 4:45 AMAhnaf
05/20/2022, 4:45 AMfunk101
05/20/2022, 4:45 AMrp_st
05/20/2022, 4:45 AMfunk101
05/20/2022, 4:45 AMAhnaf
05/20/2022, 4:46 AMAhnaf
05/20/2022, 4:46 AMrp_st
05/20/2022, 4:46 AMAhnaf
05/20/2022, 4:46 AMAhnaf
05/20/2022, 4:46 AMAhnaf
05/20/2022, 4:46 AMAhnaf
05/20/2022, 4:46 AMAhnaf
05/20/2022, 4:46 AMrp_st
05/20/2022, 4:46 AMAhnaf
05/20/2022, 4:46 AMfunk101
05/20/2022, 4:46 AMAhnaf
05/20/2022, 4:47 AMAhnaf
05/20/2022, 4:47 AMfunk101
05/20/2022, 4:47 AMAhnaf
05/20/2022, 4:47 AMAhnaf
05/20/2022, 4:47 AMAhnaf
05/20/2022, 4:47 AMfunk101
05/20/2022, 4:49 AMAhnaf
05/20/2022, 4:49 AMAhnaf
05/20/2022, 4:49 AMfunk101
05/20/2022, 4:49 AMfunk101
05/20/2022, 4:49 AMAhnaf
05/20/2022, 4:49 AMAhnaf
05/20/2022, 4:49 AMfunk101
05/20/2022, 4:49 AMAhnaf
05/20/2022, 4:50 AMAhnaf
05/20/2022, 4:50 AMAhnaf
05/20/2022, 4:50 AMhttps://www.finicky.pet
Ahnaf
05/20/2022, 4:50 AMrp_st
05/20/2022, 4:50 AMAhnaf
05/20/2022, 4:50 AMAhnaf
05/20/2022, 4:50 AMAhnaf
05/20/2022, 4:50 AMAhnaf
05/20/2022, 4:50 AMfunk101
05/20/2022, 4:51 AMrp_st
05/20/2022, 4:51 AMrp_st
05/20/2022, 4:51 AMfunk101
05/20/2022, 4:53 AMfunk101
05/20/2022, 4:53 AMfunk101
05/20/2022, 4:53 AMfunk101
05/20/2022, 4:56 AMfunk101
05/20/2022, 4:57 AMsupertokens.init(backendConfig());
export default async function superTokens(req, res) {
// NOTE: We need CORS only if we are querying the APIs from a different origin
await NextCors(req, res, {
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
origin: process.env.NEXT_PUBLIC_HOST,
credentials: true,
allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
});
await superTokensNextWrapper(
async (next) => {
await middleware()(req, res, next);
},
req,
res
);
if (!res.writableEnded) {
res.status(404).send("Not found");
}
}
rp_st
05/20/2022, 5:00 AMrp_st
05/20/2022, 5:00 AMrp_st
05/20/2022, 5:01 AMfunk101
05/20/2022, 5:01 AMrp_st
05/20/2022, 5:01 AMrp_st
05/20/2022, 5:02 AMfunk101
05/20/2022, 5:02 AMfunk101
05/20/2022, 5:03 AMNEXT_PUBLIC_HOST
Production
VALUE
https://www.finicky.pet
Updated 14m ago
NAME
NEXT_PUBLIC_HOST
VALUE
https://www.finicky.pet
ENVIRONMENT
Production
Preview
Select Custom Branch
Development
funk101
05/20/2022, 5:03 AMrp_st
05/20/2022, 5:03 AMrp_st
05/20/2022, 5:03 AMrp_st
05/20/2022, 5:04 AMrp_st
05/20/2022, 5:04 AMfunk101
05/20/2022, 5:05 AMfunk101
05/20/2022, 5:06 AMfunk101
05/20/2022, 5:06 AM_app-376a5bb26884a74a.js:1 POST https://www.finicky.pet/api/auth/session/refresh 401
funk101
05/20/2022, 5:07 AMrp_st
05/20/2022, 5:07 AMfunk101
05/20/2022, 5:08 AMfunk101
05/20/2022, 5:08 AMfunk101
05/20/2022, 5:08 AMrp_st
05/20/2022, 5:09 AMrp_st
05/20/2022, 5:09 AMfunk101
05/20/2022, 5:09 AMfunk101
05/20/2022, 5:10 AMrp_st
05/20/2022, 5:10 AMfunk101
05/20/2022, 5:11 AMrp_st
05/20/2022, 5:11 AMfunk101
05/20/2022, 5:17 AMfunk101
05/20/2022, 5:17 AMreturn {
enableDebugLogs: true,
appInfo,
recipeList: [
EmailPasswordReact.init({
getRedirectionURL: async (context) => {
if (context.action === "SUCCESS") {
if (context.redirectToPath !== undefined) {
// navigate back to where the user was before authenticated
return context.redirectToPath;
}
return "/dashboard";
}
return undefined;
},
rp_st
05/20/2022, 5:19 AMfunk101
05/20/2022, 5:19 AMrp_st
05/20/2022, 5:19 AMrp_st
05/20/2022, 5:20 AMfunk101
05/20/2022, 5:20 AMrp_st
05/20/2022, 5:20 AMfunk101
05/20/2022, 5:20 AMrp_st
05/20/2022, 5:21 AMrp_st
05/20/2022, 5:21 AMfunk101
05/20/2022, 5:24 AMfunk101
05/20/2022, 5:25 AMfunk101
05/20/2022, 5:26 AMfunk101
05/20/2022, 5:27 AMrp_st
05/20/2022, 5:44 AMEmailPasswordAuthNoSSR
?funk101
05/20/2022, 5:44 AMfunk101
05/20/2022, 5:45 AMfunk101
05/20/2022, 5:46 AMrp_st
05/20/2022, 5:56 AMrp_st
05/20/2022, 5:57 AMEmailPasswordAuthNoSSR
too?rp_st
05/20/2022, 5:57 AMfunk101
05/20/2022, 5:58 AMfunk101
05/20/2022, 5:58 AMif (typeof window !== "undefined") {
// we only want to call this init function on the frontend, so we check typeof window !== 'undefined'
SuperTokensReact.init(frontendConfig());
}
const EmailPasswordAuthNoSSR = dynamic(
new Promise((res) => res(EmailPassword.EmailPasswordAuth)),
{ ssr: false }
);
export default function App({ Component, pageProps }) {
const securityLevel = Component.securityLevel;
const getLayout = Component.getLayout || ((page) => page);
if (securityLevel === "full") {
return (
<EmailPasswordAuthNoSSR>
{getLayout(<Component {...pageProps} />)}
</EmailPasswordAuthNoSSR>
);
} else {
return (
<EmailPasswordAuthNoSSR requireAuth={false}>
{getLayout(<Component {...pageProps} />)}
</EmailPasswordAuthNoSSR>
);
}
}
rp_st
05/20/2022, 5:58 AMfunk101
05/20/2022, 5:59 AMfunk101
05/20/2022, 5:59 AMfunk101
05/20/2022, 5:59 AMrp_st
05/20/2022, 5:59 AMfunk101
05/20/2022, 6:00 AMrp_st
05/20/2022, 6:00 AMfunk101
05/20/2022, 6:00 AMfunk101
05/20/2022, 6:00 AMrp_st
05/20/2022, 6:01 AMfunk101
05/20/2022, 6:01 AMfunk101
05/20/2022, 6:01 AMfunk101
05/20/2022, 6:01 AMrp_st
05/20/2022, 6:01 AMfunk101
05/20/2022, 6:02 AMconst SuperTokensComponentNoSSR = dynamic(
new Promise((res) => res(SuperTokens.getRoutingComponent)),
{ ssr: false }
);
export default function Auth() {
// if the user visits a page that is not handled by us (like /auth/random), then we redirect them back to the auth page.
useEffect(() => {
if (SuperTokens.canHandleRoute() === false) {
redirectToAuth();
}
}, []);
return <SuperTokensComponentNoSSR />;
}
Auth.getLayout = function getLayout(page) {
return (
<Layout
pageTitle="Finicky.Pet"
contentTitle=""
metaDescription="Your online marketplace for buying and selling new and used pet items!"
canonical="/"
>
<SingleColumnLayout>{page}</SingleColumnLayout>
</Layout>
);
};
funk101
05/20/2022, 6:04 AMauth/[[...path]].js
rp_st
05/20/2022, 6:04 AMLayout
redirecting? Cause it has canonical="/"
rp_st
05/20/2022, 6:04 AMfunk101
05/20/2022, 6:04 AMfunk101
05/20/2022, 6:06 AMfunk101
05/20/2022, 6:07 AMredirectToAuth()
in useEffec()?rp_st
05/20/2022, 6:07 AMgetRedirectionURL
and see what happens?rp_st
05/20/2022, 6:07 AMrp_st
05/20/2022, 6:08 AMfunk101
05/20/2022, 6:08 AMrp_st
05/20/2022, 6:08 AMappInfo.websiteBasePath
rp_st
05/20/2022, 6:08 AMrp_st
05/20/2022, 6:09 AMfunk101
05/20/2022, 6:09 AMrp_st
05/20/2022, 6:09 AMrp_st
05/20/2022, 6:09 AMfunk101
05/20/2022, 6:10 AMfunk101
05/20/2022, 6:11 AMrp_st
05/20/2022, 6:11 AMfunk101
05/20/2022, 6:11 AMfunk101
05/20/2022, 6:12 AMfunk101
05/20/2022, 6:13 AM